class UsersController < ApplicationController

  def login
  end

  def verify
#    hash_pass = Digest::SHA1.hexdigest(params[:user][:hashed_password])[0..39]
    user = User.find(:first,:conditions => 
                      ["Username = ? and Password = ?", 
                       params[:user][:username], params[:user][:hashed_password] ])
    if user
      session['user'] = user
      redirect_to session['initial_uri']
    else    
      flash['notice'] = "Bad username/password!" 
      redirect_to :controller => "users", :action => "login" 
    end     
  end

  def logout
    reset_session
    # Redirect users to Books#admin, which in turn sends them to 
    # Users#login, with a refering url of Books#admin:
    redirect_to :category => 'index',
              :page => 'index',
              :controller => 'public', 
              :action => 'showpage'
  end
end